package com.example.qxfw.dzzh.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.CountryPoint;
import com.example.qxfw.common.entity.DisasterType;
import com.example.qxfw.common.entity.PotentialPoints;
import com.example.qxfw.dzzh.service.CountryPointService;
import com.example.qxfw.dzzh.service.DisasterTypeService;
import com.example.qxfw.dzzh.service.PotentialPointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "地质灾害-灾点查询")
@RestController
@CrossOrigin
@RequestMapping("/zdcx")
public class ZdcxController {

    @Autowired
    private CountryPointService countryPointService;

    @Autowired
    private DisasterTypeService disasterTypeService;

    @Autowired
    private PotentialPointService potentialPointService;

    @ApiOperation("获取乡镇名字")
    @RequestMapping("/getCountryName")
    public SysResult getCountryName(){
        List<CountryPoint> list = countryPointService.list();
        return SysResult.success(list);
    }

    @ApiOperation("获取灾害类型")
    @RequestMapping("/getDisasterType")
    public SysResult getDisasterType(){
        List<DisasterType> list = disasterTypeService.list();
        return SysResult.success(list);
    }

    @ApiOperation("条件查询灾点")
    @RequestMapping("/getPotentialPointByParam")
    public SysResult getPotentialPointByParam(String ppId,String ppName,String country,String disType,String disScale,String disLevel,Double threatPop1,Double threatPop2,Double threatProp1,Double threatProp2){
        List<PotentialPoints> potentialPoints = potentialPointService.listByParam(ppId, ppName, country, disType, disScale, disLevel, threatPop1, threatPop2, threatProp1, threatProp2);
        return SysResult.success(potentialPoints);
    }

    @ApiOperation("圆形查询灾点")
    @RequestMapping("/getPotentialPointByCircle")
    public SysResult getPotentialPointByCircle(double lon,double lat,double distance){
        List<PotentialPoints> potentialPoints = potentialPointService.listByDistance(lon, lat, distance);
        return SysResult.success(potentialPoints,potentialPoints.size());
    }

    @ApiOperation("多边形查询灾点")
    @RequestMapping("/getPotentialPointByPolygon")
    public SysResult getPotentialPointByPolygon(@RequestBody List<List<Double>> range){
        List<PotentialPoints> potentialPoints = potentialPointService.listByPolygon(range);
        return SysResult.success(potentialPoints);
    }



}
